#pragma once

#include <string>
#include <map>

using namespace std;

/****************************************************
  Base class of singleton pattern.
 ****************************************************/
class Singleton
{
public:
	typedef std::map<std::string, Singleton *> MapType;

        // Get the unique instance
        static Singleton * getInstance(std::string const *);
        // Release the instance
	static void release(std::string &);

        // Get the class name
	static std::string * getClassName();

        template<class T>
        static void registerClass(T * object){
            _registryMap->insert(pair<std::string, Singleton *>(*(T::getClassName()), object));
        }

        static void registerAll();

protected:
        Singleton();
        virtual ~Singleton();

	static MapType * _registryMap;
};
